1. Create an SVG document with SVG.JS 3.x

1.1 Code:

        

Style 1

    DOM:       <div id="drawing"> </div>     Script 1:     var draw = SVG().addTo('#drawing').size(1024,200); or  Script 2:     var draw = SVG().addTo('#drawing').size('100%', '100%');

Style 2

    DOM:       <div class="drawing"> </div>     Script 1:     var draw = SVG().addTo('.drawing').size(1024,200); or  Script 2:     var draw = SVG().addTo('.drawing').size('100%', '100%');

Style 3

    DOM:       <svg id="drawing"> </svg>     Script 1:     var draw = SVG('#drawing').size(1024, 200); or  Script 2:     var draw = SVG('#drawing').size('100%', '100%');

Style 4 (no need to offer dom element, but hard to control the position of svg document)

    Script:     var draw = SVG().addTo('body').size(300, 300);

1.2 Result:

2. Create an SVG document with SVG.JS 2.x

2.1 Code:

        var draw = SVG('drawing').size(300, 300)
        var rect = draw.rect(100, 100).attr({ fill: '#f06' })      

2.2 Result:

Oops, it does'nt work by default! You can save this page or download this file from Github and change the SVG.js vertion to v2.x to make this svg document running!